package cn.woochen.comlib.config

import android.content.Context
import androidx.startup.Initializer
import com.kingja.loadsir.callback.SuccessCallback
import com.kingja.loadsir.core.LoadSir
import cn.woochen.comlib.loadinglayout.EmptyCallBack
import cn.woochen.comlib.loadinglayout.ErrorCallback
import cn.woochen.comlib.loadinglayout.LoadingCallBack
import cn.woochen.comlib.loadinglayout.LoadingHasContentCallBack
import cn.woochen.comlib.util.ApplicationUtil
import cn.woochen.comlib.util.ConfigPref
import cn.woochen.comlib.util.UserPref
import com.hjq.toast.ToastUtils

class LibInitializer:Initializer<Unit> {
    override fun create(context: Context) {
        //context init
        ApplicationUtil.context = context
        //loadSir
        LoadSir.beginBuilder().addCallback(ErrorCallback())
            .addCallback(EmptyCallBack())
            .addCallback(LoadingCallBack())
            .addCallback(LoadingHasContentCallBack())
            .setDefaultCallback(SuccessCallback::class.java).commit()
        //sp init
        UserPref.init(context)
        ConfigPref.init(context)
    }

    override fun dependencies(): MutableList<Class<out Initializer<*>>> {
        return mutableListOf()
    }
}